{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on module cntext.similarity in cntext:\n",
      "\n",
      "NAME\n",
      "    cntext.similarity - # -*- coding: utf-8 -*-\n",
      "\n",
      "FUNCTIONS\n",
      "    cosine_sim(text1, text2)\n",
      "        对输入的text1和text2进行相似性计算，返回相似性信息\n",
      "        :param text1:  文本字符串\n",
      "        :param text2: 文本字符串\n",
      "        :return:  返回相似度数值结果\n",
      "    \n",
      "    jaccard_sim(text1, text2)\n",
      "        jaccard相似度算法; \n",
      "        :param text1:  文本字符串\n",
      "        :param text2: 文本字符串\n",
      "        :return:  返回相似度数值结果\n",
      "    \n",
      "    minedit_sim(text1, text2)\n",
      "        最小编辑距离相似度算法； \n",
      "        :param text1:  文本字符串\n",
      "        :param text2: 文本字符串\n",
      "        :return:  返回相似度数值结果\n",
      "    \n",
      "    simple_sim(text1, text2)\n",
      "        更改变动算法。\n",
      "        参考微软word中的track change函数和Unix系统中的diff函数。\n",
      "        :param text1:  文本字符串\n",
      "        :param text2: 文本字符串\n",
      "        :return:  返回相似度数值结果\n",
      "\n",
      "FILE\n",
      "    /Library/Frameworks/anaconda3/lib/python3.9/site-packages/cntext/similarity.py\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "from cntext import similarity\n",
    "\n",
    "help(similarity)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Building prefix dict from the default dictionary ...\n",
      "Loading model from cache /var/folders/sc/3mnt5tgs419_hk7s16gq61p80000gn/T/jieba.cache\n",
      "Loading model cost 0.563 seconds.\n",
      "Prefix dict has been built successfully.\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "0.9999999999999998"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from cntext import cosine_sim\n",
    "\n",
    "text1 = '编程真好玩编程真好玩'\n",
    "text2 = '游戏真好玩编程真好玩'\n",
    "\n",
    "cosine_sim(text1, text2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1.0"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from cntext import jaccard_sim\n",
    "\n",
    "jaccard_sim(text1, text2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from cntext import minedit_sim\n",
    "\n",
    "minedit_sim(text1, text2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.84375"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from cntext import simple_sim\n",
    "\n",
    "simple_sim(text1, text2)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
